#pragma once

#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <sstream>
#include <cerrno>
#include <cstdio>
#include <strings.h>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#include <set>
#include <unordered_map>

#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

using namespace std;

#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)                        // 为了代码好看？？
#define CONV(v) (struct sockaddr *)(v) // 强转

enum
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    EPOLL_CREATE_ERR,
    EPOLL_CTL_ERR
};

bool ParseOneLine(std::string& s, std::string* out, std::string Sep)
{
    auto pos = s.find(Sep);
    if(pos == std::string::npos) return false;
    *out = s.substr(0,pos);
    s.erase(0, pos+Sep.size());
    return true;
}